package be.sc.classicnetwork.service.impl;

import java.util.ArrayList;
import java.util.Collection;

import org.springframework.transaction.annotation.Transactional;

import be.sc.classicnetwork.dao.CodeDao;
import be.sc.classicnetwork.model.Code;
import be.sc.classicnetwork.model.Make;
import be.sc.classicnetwork.service.CodeService;

/**
 * CodeServiceImpl.
 */
@Transactional
public class CodeServiceImpl implements CodeService {

	private CodeDao codeDao;

	/**
	 * @see be.sc.classicnetwork.service.CarService#findCodeById(int)
	 */
	public Code findById(Class<? extends Code> codeClass, int id) {
		return getCodeDao().findById(codeClass, id);
	}

	/**
	 * @see be.sc.classicnetwork.service.CodeService#findAll(java.lang.Class)
	 */
	public Collection<? extends Code> findAll(Class<? extends Code> codeClass) {
		return getCodeDao().findAll(codeClass);
	}

	/**
	 * @see be.sc.classicnetwork.service.CodeService#findByIdIn(java.lang.Class,
	 *      java.lang.Integer[])
	 */
	public Collection<? extends Code> findByIdIn(
			Class<? extends Code> codeClass, String... ids) {
		if (ids == null || ids.length == 0) {
			return new ArrayList<Make>();
		}
		return getCodeDao().findByIdIn(codeClass, ids);
	}

	public CodeDao getCodeDao() {
		return codeDao;
	}

	public void setCodeDao(CodeDao codeDao) {
		this.codeDao = codeDao;
	}
}
